package com.lk.web;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.lk.entity.Employee;
import com.lk.entity.IdeaDiscuss;
import com.lk.util.Const;
import com.lk.util.DateUtil;
import com.lk.util.PKUtil;
import com.lk.util.StringUtil;

public class IdeaDiscussServlet extends HttpServlet {


	private static final long serialVersionUID = 1L;

	public void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		String discuss = request.getParameter("_d");
		if(StringUtil.isEmpty(discuss)){
			list(request,response);
		} else if ("save".equals(discuss)){
			save(request,response);
		}
	}

	private void save(HttpServletRequest request,HttpServletResponse response) 
			throws ServletException, IOException {
		String id = request.getParameter("id");
		String content = request.getParameter("new_discuss");
		System.out.println(id + "<<<<<<<>>>>>>>>>>>>>" + content);
		IdeaDiscuss dis = new IdeaDiscuss();
		dis.setId_id(PKUtil.getPK());
		dis.setId_creatTime(DateUtil.getDate());
		dis.setId_content(content);
		dis.setT_idea_id(id);
		
		HttpSession session = request.getSession();
		Employee e = (Employee)session.getAttribute(Const.USER_IN_SESSION);
		dis.setT_employee_id(e.getId());
		if(StringUtil.isNotEmpty(content)){
			
		}
	}

	private void list(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.getRequestDispatcher("/WEB-INF/views/show_idea.jsp").forward(request, response);
	}


}
